<?php

namespace App\Http\Controllers;

use App\Services\BaseService;
use App\Services\System\SystemService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class HomeController extends BaseController
{

    //首页
    public function index(Request $request) {
        if (!Auth::id()){
            return redirect("login");
        }
        $user = Auth::user();
        $this->view_data['is_admin'] = $user['is_admin'];
        return view("welcome", $this->view_data);
    }

    /**
     * 获取城市、区县信息
     * @param Request $request
     * @return void
     */
    public function province(Request $request) {
        $code = $request->get("code", 0);
        $list = (new BaseService())->getProvinceChildList($code);
        return $this->apiSuccess($list);
    }
}
